<#assign script_controller = 'group/group'/>
<@block_title "${groupinfo.title}小组" />
<#assign metaKeywords = "${groupinfo.title}小组 ${setting('site.name')}" />
<#assign metaDescription = "${(groupinfo.about)!''?substring(0, 150)}" />
<#assign groupNav = 'index'/>

<#include '/group/layout.ftl'/>

<#macro blockGroupMain>
  <div class="panel panel-default">
    <div class="panel-body">
      <#if paginator.currentPage == paginator.firstPage>
        <div class="alert alert-info clearfix">
          <#if groupinfo.about??> ${groupinfo.about} <#else> 暂无简介 </#if>
          <hr>
          <div class="">
            <#if is_groupmember==0>
              <a id="add-btn" class="btn btn-info btn-sm pull-right" href="${ctx}/group/${groupinfo.id}/join">加入小组</a>
            </#if>

            <span class="text-muted fsn mrm">创建时间：${groupinfo.createdTime?number_to_datetime?string('yyyy-MM-dd')}</span>
            <span class="text-muted fsn mrm">组长：<@web_macro.user_link groupOwner, 'link-muted '/></span>

            <#if is_groupmember==1 || is_groupmember==3>
              <span class="text-muted fsn ">你已经是小组成员，
              <a  id="exit-btn" class="text-muted" href="${ctx}/group/${groupinfo.id}/exit"> &raquo; 退出小组</a></span>
            </#if>

          </div>
        </div>
      </#if>
      <@web_macro.flash_messages/>
      <div class="clearfix mbl">

      <ul class="nav nav-pills nav-mini  pull-left ">

        <li<#if condition.type == 'all'> class="active"</#if>><a class="js-nav" data-target="#thread-pane" href="${ctx}/group/${id}?num=${condition.num}&sort=${condition.sort}&isElite=0">全部</a></li>
            
        <li<#if condition.type == 'elite'> class="active"</#if>><a class="js-nav" data-target="#thread-pane" href="${ctx}/group/${id}?type=elite&num=${condition.num}&sort=${condition.sort}">精华</a></li>

        <#if is_feature_enabled('group_reward') >
        <li<#if condition.type == 'reward'> class="active"</#if>><a class="js-nav" data-target="#thread-pane" href="${ctx}/group/${id}?type=reward&num=${condition.num}&sort=${condition.sort}">悬赏</a></li>
        </#if>
        
        <li><span class="mhm text-muted">|</span></li>

        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#">
            <span class="text-muted">排序：</span>
            <#if condition.sort == 'byLastPostTime' >
              最后回复
            <#elseif condition.sort == 'byCreatedTime'>
              最新发帖
            <#elseif condition.sort == 'byPostNum'>
              回复数
            </#if>
            <span class="caret"></span>
          </a>

          <ul class="dropdown-menu">
            <li class="<#if condition.sort == 'byCreatedTime'>active</#if>"><a class="js-nav" href="${ctx}/group/${id}?isElite=${condition.type}&num=${condition.num}&sort=byCreatedTime">最新发帖</a></li>
            <li class="<#if condition.sort == 'byLastPostTime'>active</#if>"><a class="js-nav" href="${ctx}/group/${id}?isElite=${condition.type}&num=${condition.num}&sort=byLastPostTime">最后回复</a></li>
            <li class="<#if condition.sort == 'byPostNum'>active</#if>"><a class="js-nav" href="${ctx}/group/${id}?isElite=${condition.type}&num=${condition.num}&sort=byPostNum">回复数</a></li>
          </ul>

        </li>

      </ul>

      <#if is_groupmember !=0 >
          <div class="pull-right"><a href="${ctx}/group/${groupinfo.id}/thread/create" class="btn btn-primary btn-sm " role="button">发话题</a>
          </div>
      </#if>

      </div>

      <#include '/group/groups-threads-ul.ftl'/>

      <@web_macro.paginator paginator!/>
    </div>
  </div>

</#macro>

<#macro blockGroupSide>

  <#if is_groupmember == 1 || is_groupmember == 2 || is_groupmember == 3>
    <div class="panel panel-default">
      <div class="panel-heading">我在小组</div>
      <div class="panel-body">
        <div class="media">
          <@web_macro.user_avatar user  ' pull-left media-object media-object-small'/>

          <div class="media-body">
            <p><@web_macro.user_link user 'link-muted'/>

              <#if is_groupmember==1>
              <span class="label label-success">组员</span>
              </#if>

              <#if is_groupmember==2>
              <span class="label label-info">组长</span>  
              </#if>

              <#if is_groupmember==3>
              <span class="label label-info">副组长</span>  
              </#if>
            </p>

            <p class="text-muted fsn">
              <span class="mrm">我的话题: ${(userIsGroupMember.threadNum)!}</span>
              <span>我的回复: ${(userIsGroupMember.postNum)!}</span>
            </p>
          </div>

        </div>
      </div>
    </div>
  </#if>

  <div class="panel panel-default">
    <div class="panel-heading">最近加入</div>
    <div class="panel-body">
      <#if recentlyJoinMember??>
        <ul class="user-grids">
          <#list recentlyJoinMember as member>
            <li style="width:22%;">
              <@web_macro.user_avatar members[member.userId?c]  'pull-left media-object media-object-small'/><p ><@web_macro.user_link members[member.userId?c] , 'link-muted'/></p>
            </li>
          </#list>
        </ul>
      <#else>
        还没有小组成员！
      </#if>
    </div>
  </div>



      <form action="${ctx}/group/${groupinfo.id}/search" method="get">
        <div class="input-group">
          <input type="hidden" name="_csrf_token" value="${csrf_token('site')}">
          <input type="text" class="form-control" placeholder="组内搜索" name="keyWord">
          <span class="input-group-btn">
          <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
          </span>
        </div>
      </form>

</#macro>